<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>挖股机 - 挖掘最具价值的股票</title>
	<link rel="stylesheet" type="text/css" href="scripts/ext-3.3.1/resources/css/ext-all.css"/>
	<link rel="stylesheet" type="text/css" href="styles/global.css"/>
	<script type="text/javascript" src="scripts/ext-3.3.1/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="scripts/ext-3.3.1/ext-all.js"></script>
	<script>
	Ext.BLANK_IMAGE_URL="scripts/ext-3.3.1/resources/images/default/s.gif";
	function build_navigator(){
		var root = new Ext.tree.AsyncTreeNode({
			id:"root",
			text:"Stock Service"
		});
		
		var navigator = new Ext.tree.TreePanel({
			title:"导航",
			region:"west",
			width:180,
			collapsible:false,
			split:true,
			rootVisible:false,
			loader: new Ext.tree.TreeLoader({
				dataUrl: "<s:url action='navigator'/>"
			})
		});
		
		navigator.setRootNode(root);
		
		return navigator;
	}

	function build_header(){
		var header = new Ext.Panel({
			title:"header",
			region:"north",
			height:0,
			html:'<iframe frameborder="0" scrolling="no" width="100%" height="100%" src="header.html"></iframe>',
			header:false
		});
		return header;
	}

	function build_footer(){
		var footer = new Ext.Panel({
			title:"footer",
			region:"south",
			height:0,
			html:'<iframe frameborder="0" scrolling="no" width="100%" height="100%" src="footer.html"></iframe>',
			header:false
		});
		
		return footer;
	}

	function build_main(){
		var main = new Ext.TabPanel({
			title:"Main",
			region:"center"
		});
		
		return main;
	}

	Ext.onReady(function(){
		var header = build_header();
		var footer = build_footer();
		var main = build_main();
		var navigator = build_navigator();

		var vp = new Ext.Viewport({
			layout:"border",
			items:[header,footer,navigator,main]
		});
		
		navigator.expandAll();
		
		navigator.on("click",function(n){
			var url = n.attributes.url;
			var id = n.attributes.id;
			if(url){
				var p = main.getItem(id);
				if(p){
					main.setActiveTab(p);
				}else{
					var p = new Ext.Panel({
						title:n.attributes.text,
						html:'<iframe class="main" scrolling="auto" frameborder="0" width="98%" height="100%" src='+url+'></iframe>',
						closable:true,
						id:id
					});
					main.add(p);
					main.setActiveTab(p);
				}
			}
		});
	});
	</script>
</head>
<body>
</body>
</html>